package com.lucky.auth_boot.controller;

import com.lucky.auth_boot.common.Result;
import com.lucky.auth_boot.mapper.RolesMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@Controller
public class hello {
    @Autowired
    DataSource dataSource;

    @Resource
    RolesMapper rolesMapper;

    @RequestMapping("/")
    public String view() {
        return "forward:index.html";
    }

    @PreAuthorize("hasAnyRole('admin')")
    @GetMapping("/world")
    public Result<?> test2() {
//        authListService.listAuthList();
        return Result.success("world !");
    }

//    @DisplayName("查看 数据库连接池")
@GetMapping("/dataSource")
    void contextLoads() {
        System.out.println(dataSource.getClass().getName());
    }
}
